import { createRouter, createWebHistory } from 'vue-router'
import { useMenuStore } from '@/stores'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
		{
			path: '/',
			name: 'Home',
			component: () => import('@/views'),
			meta: {
				title: '首页'
			},
			children: [
				{
					path: '/bed',
					name: 'Bed',
					component: () => import('@/views/bed'),
					meta: {
						title: '床位示意图'
					}
				},
				{
					path: '/bedManager',
					name: 'BedManager',
					component: () => import('@/views/bed/list'),
					meta: {
						title: '床位管理'
					}
				},
				{
					path: '/room/list',
					name: 'RoomList',
					component: () => import('@/views/dict/room'),
					meta: {
						title: '房间列表'
					}
				},
				{
					path: '/bed/list',
					name: 'BedList',
					component: () => import('@/views/dict/bed'),
					meta: {
						title: '床位列表'
					}
				},
				{
					path: '/inroom',
					name: 'InRoom',
					component: () => import('@/views/customer/inroom'),
					meta: {
						title: '入住管理'
					}
				},
				{
					path: '/food',
					name: 'Food',
					component: () => import('@/views/customer/food'),
					meta: {
						title: '膳食管理'
					}
				},
				{
					path: '/meal',
					name: 'Meal',
					component: () => import('@/views/customer/meal'),
					meta: {
						title: '膳食日历'
					}
				},
				{
					path: '/nursecontent',
					name: 'NurseContent',
					component: () => import('@/views/nurse/content'),
					meta: {
						title: '护理项目'
					}
				},
				{
					path: '/nurselevel',
					name: 'NurseLevel',
					component: () => import('@/views/nurse/level'),
					meta: {
						title: '护理级别'
					}
				},
				{
					path: '/customernurseitem',
					name: 'CustomerNurseItem',
					component: () => import('@/views/nurse/customer'),
					meta: {
						title: '护理级别'
					}
				}
			]
		}
	],
})
router.beforeEach((to, from, next) => {
	const menuStore = useMenuStore()
	menuStore.addMenu({
		text: to.meta.title,
		path: to.path
	})
  document.title = to.meta.title
	next()
})
export default router
